//
//  YGFoodManagerViewController.m
//  yuanshangyiliao
//
//  Created by icholab on 2021/4/2.
//

#import "YGFoodManagerViewController.h"
#import "YGBodyDataViewController.h"
#import "YGFoodGuideViewController.h"
#import "YGFoodSurveyViewController.h"
#import "YGFoodWikipediaViewController.h"

@interface YGFoodManagerViewController ()

@property (nonatomic, strong) UIImageView *bannerImage;
@property (nonatomic, strong) UIButton *foodSurveyBtn;
@property (nonatomic, strong) UIButton *foodGuideBtn;
@property (nonatomic, strong) UIButton *foodWikipediaBtn;
@property (nonatomic, strong) UIButton *bodyDataBtn;

@property (nonatomic, strong) UIImageView *foodSurveyImage;
@property (nonatomic, strong) UIImageView *foodGuideImage;
@property (nonatomic, strong) UIImageView *foodWikepediaImage;
@property (nonatomic, strong) UIImageView *bodyDataImage;


@end

@implementation YGFoodManagerViewController


#pragma private
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setTitle:@"膳食管理"];
    //设置导航栏属性
    self.navigationController.navigationBar.barTintColor = UIColorFromRGB(0x37C8D7);
//    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : UIColorFromRGB(0xffffff)}];
    
    [self initView];
    [self initcontraints];
}

-(void)initView{
    
    [self.view addSubview:self.bannerImage];
    [self.view addSubview:self.foodGuideBtn];
    [self.view addSubview:self.foodSurveyBtn];
    [self.view addSubview:self.bodyDataBtn];
    [self.view addSubview:self.foodWikipediaBtn];
    
    [self.foodGuideBtn addSubview:self.foodGuideImage];
    [self.foodSurveyBtn addSubview:self.foodSurveyImage];
    [self.bodyDataBtn addSubview:self.bodyDataImage];
    [self.foodWikipediaBtn addSubview:self.foodWikepediaImage];
    
    
}

-(void)initcontraints{
    
    [self.bannerImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.view).offset(91);
            make.left.right.mas_equalTo(self.view);
            make.height.mas_equalTo(180);
    }];
    //btn的自动布局
    [self.foodSurveyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.bannerImage.mas_bottom).offset(20);
            make.left.mas_equalTo(self.view).offset(10);
            make.width.mas_equalTo(172.5);
            make.height.mas_equalTo(110);
    }];
    
    [self.foodGuideBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.bannerImage.mas_bottom).offset(20);
            make.left.mas_equalTo(self.foodSurveyBtn.mas_right).offset(10.5);
            make.right.mas_equalTo(self.view).offset(-10);
            make.width.mas_equalTo(172.5);
            make.height.mas_equalTo(110);
    }];
    
    [self.foodWikipediaBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.foodSurveyBtn.mas_bottom).offset(10);
            make.left.mas_equalTo(self.foodSurveyBtn.mas_left);
            make.right.mas_equalTo(self.foodSurveyBtn.mas_right);
            make.width.mas_equalTo(172.5);
            make.height.mas_equalTo(110);
    
    [self.bodyDataBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.foodGuideBtn.mas_bottom).offset(10);
            make.left.mas_equalTo(self.foodGuideBtn.mas_left);
            make.width.mas_equalTo(172.5);
            make.height.mas_equalTo(110);
            
    }];
    
   
            
    }];
    //图片的布局
    [self.foodSurveyImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.foodSurveyBtn.mas_top).offset(20);
            make.centerX.mas_equalTo(self.foodSurveyBtn.mas_centerX);
    }];
    
    [self.foodGuideImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.foodGuideBtn.mas_top).offset(20);
            make.centerX.mas_equalTo(self.foodGuideBtn.mas_centerX);
    }];
    
    [self.bodyDataImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.bodyDataBtn.mas_top).offset(20);
            make.centerX.mas_equalTo(self.bodyDataBtn.mas_centerX);
    }];
    
    [self.foodWikepediaImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.foodWikipediaBtn.mas_top).offset(20);
            make.centerX.mas_equalTo(self.foodWikipediaBtn.mas_centerX);
    }];
    
   
}

#pragma event

-(void)clickFoodSurveyBtnAction{
    
    YGFoodSurveyViewController *vc = [[YGFoodSurveyViewController alloc]init];
    UIBarButtonItem *barbuttonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:nil action:nil];
    barbuttonItem.tintColor = UIColorFromRGB(0xffffff);
    self.navigationItem.backBarButtonItem = barbuttonItem;
    [self.navigationController pushViewController:vc animated:YES];
}

-(void)clickFoodGuideBtnAction{
    
    YGFoodGuideViewController *vc = [[YGFoodGuideViewController alloc]init];
    UIBarButtonItem *barbuttonItem = [[UIBarButtonItem alloc]initWithTitle:@"" style:UIBarButtonItemStyleDone target:nil action:nil];
    barbuttonItem.tintColor = UIColorFromRGB(0xffffff);
    self.navigationItem.backBarButtonItem = barbuttonItem;
    [self.navigationController pushViewController:vc animated:YES];
}

-(void)clickFoodWikipediaBtnAction{
    YGFoodWikipediaViewController *vc = [[YGFoodWikipediaViewController alloc]init];
    UIBarButtonItem *barbuttonItem = [[UIBarButtonItem alloc]initWithTitle:@"" style:UIBarButtonItemStyleDone target:nil action:nil];
    barbuttonItem.tintColor = UIColorFromRGB(0xffffff);
    self.navigationItem.backBarButtonItem = barbuttonItem;
    [self.navigationController pushViewController:vc animated:YES];
}

-(void)clickBodyDataBtnAction{
    
    YGBodyDataViewController *vc = [[YGBodyDataViewController alloc]init];
    //修改返回按钮的文字
    UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:nil action:nil];
    barButtonItem.tintColor=UIColorFromRGB(0xffffff);
    self.navigationItem.backBarButtonItem = barButtonItem;
    
    [self.tabBarController setHidesBottomBarWhenPushed:YES];
    
    [self.navigationController pushViewController:vc animated:YES];
    
}



#pragma setter

- (UIImageView *)bannerImage{
    if (!_bannerImage) {
        _bannerImage = [[UIImageView alloc] init];
        [_bannerImage setImage:[UIImage imageNamed:@"food_man_banner_icon"]];
    }
    return _bannerImage;
}

- (UIButton *)foodSurveyBtn{
    if (!_foodSurveyBtn) {
        _foodSurveyBtn = [[UIButton alloc]init];
        _foodSurveyBtn.backgroundColor = [UIColor whiteColor];
        _foodSurveyBtn.layer.cornerRadius = 5;
        _foodSurveyBtn.clipsToBounds = YES;
        [_foodSurveyBtn addTarget:self action:@selector(clickFoodSurveyBtnAction) forControlEvents:UIControlEventTouchUpInside];
        
        
        UILabel *titleLable = [[UILabel alloc]init];
        titleLable.text=@"膳食管理";
        titleLable.textColor = UIColorFromRGB(0x333333);
        [titleLable setFont:[UIFont systemFontOfSize:16]];
        [_foodSurveyBtn addSubview:titleLable];
        
        [titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.centerX.mas_equalTo(self.foodSurveyBtn.mas_centerX);
                    make.bottom.mas_equalTo(self.foodSurveyBtn.mas_bottom).offset(-23);
                    
        }];
        
        UILabel *detailLable = [[UILabel alloc]init];
        detailLable.text =@"记录你的每一天膳食";
        detailLable.textColor = UIColorFromRGB(0x999999);
        [detailLable setFont:[UIFont systemFontOfSize:12]];
        [_foodSurveyBtn addSubview:detailLable];
        
        [detailLable mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.centerX.mas_equalTo(self.foodSurveyBtn.mas_centerX);
                    make.top.mas_equalTo(self.foodSurveyBtn.titleLabel.mas_bottom).offset(67);
                    
        }];
        
        
    }
    return _foodSurveyBtn;
}

- (UIButton *)foodGuideBtn{
    if (!_foodGuideBtn) {
        _foodGuideBtn = [[UIButton alloc] init];
        _foodGuideBtn.backgroundColor = [UIColor whiteColor];
        _foodGuideBtn.layer.cornerRadius = 5;
        _foodGuideBtn.clipsToBounds = YES;
        [_foodGuideBtn addTarget:self action:@selector(clickFoodGuideBtnAction) forControlEvents:UIControlEventTouchUpInside];
        
        UILabel *titleLable = [[UILabel alloc]init];
        titleLable.text=@"饮食指南";
        titleLable.textColor = UIColorFromRGB(0x333333);
        [titleLable setFont:[UIFont systemFontOfSize:16]];
        [_foodGuideBtn addSubview:titleLable];
        
        [titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.centerX.mas_equalTo(self.foodGuideBtn.mas_centerX);
                    make.bottom.mas_equalTo(self.foodGuideBtn.mas_bottom).offset(-23);
                    
        }];
        
        UILabel *detailLable = [[UILabel alloc]init];
        detailLable.text =@"你的每一天的指南";
        detailLable.textColor = UIColorFromRGB(0x999999);
        [detailLable setFont:[UIFont systemFontOfSize:12]];
        [_foodGuideBtn addSubview:detailLable];
        
        [detailLable mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.centerX.mas_equalTo(self.foodGuideBtn.mas_centerX);
                    make.top.mas_equalTo(self.foodGuideBtn.titleLabel.mas_bottom).offset(67);
                    
        }];
        
    }
    return _foodGuideBtn;
}

- (UIButton *)foodWikipediaBtn{
    if (!_foodWikipediaBtn) {
        _foodWikipediaBtn = [[UIButton alloc]init];
        _foodWikipediaBtn.backgroundColor = [UIColor whiteColor];
        _foodWikipediaBtn.layer.cornerRadius = 5;
        _foodWikipediaBtn.clipsToBounds = YES;
        [_foodWikipediaBtn addTarget:self action:@selector(clickFoodWikipediaBtnAction) forControlEvents:UIControlEventTouchUpInside];
        
        UILabel *titleLable = [[UILabel alloc]init];
        titleLable.text=@"食材百科";
        titleLable.textColor = UIColorFromRGB(0x333333);
        [titleLable setFont:[UIFont systemFontOfSize:16]];
        [_foodWikipediaBtn addSubview:titleLable];
        
        [titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.centerX.mas_equalTo(self.foodWikipediaBtn.mas_centerX);
                    make.bottom.mas_equalTo(self.foodWikipediaBtn.mas_bottom).offset(-23);
                    
        }];
        
        UILabel *detailLable = [[UILabel alloc]init];
        detailLable.text =@"关于食品的百科全书";
        detailLable.textColor = UIColorFromRGB(0x999999);
        [detailLable setFont:[UIFont systemFontOfSize:12]];
        [_foodWikipediaBtn addSubview:detailLable];
        
        [detailLable mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.centerX.mas_equalTo(self.foodWikipediaBtn.mas_centerX);
                    make.top.mas_equalTo(self.foodWikipediaBtn.titleLabel.mas_bottom).offset(67);
                    
        }];
        
    }
    return _foodWikipediaBtn;
}

- (UIButton *)bodyDataBtn{
    if (!_bodyDataBtn) {
        _bodyDataBtn = [[UIButton alloc]init];
        _bodyDataBtn.backgroundColor = [UIColor whiteColor];
        _bodyDataBtn.layer.cornerRadius = 5;
        _bodyDataBtn.clipsToBounds = YES;
        [_bodyDataBtn addTarget:self action:@selector(clickBodyDataBtnAction) forControlEvents:UIControlEventTouchUpInside];
        
        UILabel *titleLable = [[UILabel alloc]init];
        titleLable.text=@"体格数据";
        titleLable.textColor = UIColorFromRGB(0x333333);
        [titleLable setFont:[UIFont systemFontOfSize:16]];
        [_bodyDataBtn addSubview:titleLable];
        
        [titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.centerX.mas_equalTo(self.bodyDataBtn.mas_centerX);
                    make.bottom.mas_equalTo(self.bodyDataBtn.mas_bottom).offset(-23);
                    
        }];
        
        UILabel *detailLable = [[UILabel alloc]init];
        detailLable.text =@"记录每天的身体数据";
        detailLable.textColor = UIColorFromRGB(0x999999);
        [detailLable setFont:[UIFont systemFontOfSize:12]];
        [_bodyDataBtn addSubview:detailLable];
        
        [detailLable mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.centerX.mas_equalTo(self.bodyDataBtn.mas_centerX);
                    make.top.mas_equalTo(self.bodyDataBtn.titleLabel.mas_bottom).offset(67);
                    
        }];
        
    }
    return _bodyDataBtn;
}



- (UIImageView *)foodSurveyImage{
    if (!_foodSurveyImage) {
        _foodSurveyImage = [[UIImageView alloc]init];
        [_foodSurveyImage setImage:[UIImage imageNamed:@"food_man_survey_icon"]];
    }
    return _foodSurveyImage;
}

- (UIImageView *)foodGuideImage{
    if (!_foodGuideImage) {
        _foodGuideImage = [[UIImageView alloc]init];
        [_foodGuideImage setImage:[UIImage imageNamed:@"food_man_guide_icon"]];
    }
    return _foodGuideImage;
}

- (UIImageView *)bodyDataImage{
    if (!_bodyDataImage) {
        _bodyDataImage = [[UIImageView alloc]init];
        [_bodyDataImage setImage:[UIImage imageNamed:@"food_man_data_icon"]];
    }
    return _bodyDataImage;
}

- (UIImageView *)foodWikepediaImage{
    if (!_foodWikepediaImage) {
        _foodWikepediaImage = [[UIImageView alloc]init];
        [_foodWikepediaImage setImage:[UIImage imageNamed:@"food_man_wikipedia_icon"]];
    }
    return _foodWikepediaImage;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
